package com.smile.cart.controller;

import com.smile.cart.interceptor.CartInterceptor;
import com.smile.cart.service.CartService;
import com.smile.cart.to.UserInfoTo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;

@Controller
public class CartServerController {
    @Resource
    private CartService cartService;

    @GetMapping("/cart.html")
    public String cartListPage()  {
        //快速得到用户信息：id,user-key
         UserInfoTo userInfoTo = CartInterceptor.toThreadLocal.get();
        System.out.println(userInfoTo);
//        CartVo cartVo = cartService.getCart();
//        model.addAttribute("cart",cartVo);
        return "cartList";
    }

    /**
     * 添加到购物车
     */
    @GetMapping("/addCartItem")
    public String addCart(@RequestParam("skuId") Long id,@RequestParam("num") Integer num){
        return "success";
    }
}
